package no.mehdi.game.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

/**
 * The player domain object.
 * 
 * @author Mehdi Zare
 * 
 */
@Entity
@Table(name = "T_PLAYER")
public class Player implements Serializable {

	private static final long serialVersionUID = 1462227044409117305L;

	@Id
	@Column(name = "PLAYER_ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long playerId;

	@Column(name = "PLAYER_NAME")
	private String playerName;

	@Column(name = "PASSWORD")
	private String password;

	@Column(name = "LOSS")
	private int loss;

	@Column(name = "WIN")
	private int win;

	@Column(name = "USER_LOGGED_IN")
	private boolean userLogedIn;

	@Version
	@Column(name = "VERSION")
	private int version;

	/**
	 * Add 1 win the player
	 */
	public void addWin() {
		win++;
	}

	/**
	 * Add One loss to player
	 */
	public void addLoss() {
		loss++;
	}

	/**
	 * @return the playerId
	 */
	public Long getPlayerId() {
		return playerId;
	}

	/**
	 * @param playerId
	 *            the playerId to set
	 */
	public void setPlayerId(Long playerId) {
		this.playerId = playerId;
	}

	/**
	 * @return the playerName
	 */
	public String getPlayerName() {
		return playerName;
	}

	/**
	 * @param playerName
	 *            the playerName to set
	 */
	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}

	/**
	 * @return the loss
	 */
	public int getLoss() {
		return loss;
	}

	/**
	 * @param loss
	 *            the loss to set
	 */
	public void setLoss(int loss) {
		this.loss = loss;
	}

	/**
	 * @return the win
	 */
	public int getWin() {
		return win;
	}

	/**
	 * @param win
	 *            the win to set
	 */
	public void setWin(int win) {
		this.win = win;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param version
	 *            the version to set
	 */
	public void setVersion(int version) {
		this.version = version;
	}

	/**
	 * @return the version
	 */
	public int getVersion() {
		return version;
	}

	/**
	 * @return the userLogedIn
	 */
	public boolean isUserLogedIn() {
		return userLogedIn;
	}

	/**
	 * @param userLogedIn
	 *            the userLogedIn to set
	 */
	public void setUserLogedIn(boolean userLogedIn) {
		this.userLogedIn = userLogedIn;
	}

}
